<%@ Page language="c#" Codebehind="CreatePage.aspx.cs" AutoEventWireup="True" Inherits="CrossFactory.SiteNote.Admin.CreatePage" %>
<HTML>
	<HEAD>
		<title>Create page</title>
		<LINK href="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Stylesheets/StyleSheet.aspx" type="text/css" rel="stylesheet">
		<script language="javascript" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Scripts/website.js"></script>
		<script language="javascript">
			function load()
			{
				//window.resizeTo(365,300);
				ResizeDialogBoxSiteNote();
			}
			function ClosePage(newPageUrl)
			{
				if(newPageUrl != undefined && newPageUrl != null && newPageUrl != "")
				{
					window.opener.navigate(newPageUrl);
				}
				window.close();
			}
			function ValidateCaracters()
			{
				var field;

				field = window.event.srcElement;
				//alert(field.allowedCaracters);
				
				if (typeof(field.allowedCaracters) != 'undefined')
				{
					if (field.value != 'undefined')
					{
						if (event.keyCode != 8 && typeof(field.maxCaracters) != 'undefined')
						{
							if (field.value.length >= field.maxCaracters)
							{
								window.event.returnValue = false;
							}
						}
					}
					
					if (event.keyCode != 8 && field.allowedCaracters.indexOf(String.fromCharCode(event.keyCode)) == -1)
					{
						if (event.keyCode != 16)
						{
							//alert(String.fromCharCode(event.keyCode));
						}
						window.event.returnValue = false;
					}
					else
					{
						if (String.fromCharCode(event.keyCode) == '0')
						{
							//alert(event.keyCode);
						}
					}
				}
			}
			function CheckChanges()
			{
				var field;
				var oField;
				var fieldRequired;
				var valueCheck;
				
				field = window.event.srcElement;
				
				if (field != null && typeof(field.allowedCaracters) != 'undefined' && event.keyCode != 37 && event.keyCode != 40)
				{
				//alert(field.value);
					if (field.value != 'undefined')
					{
						valueCheck = field.value;
						for(i=0; i<field.value.length; i++)
						{
							car = field.value.substring(i, i+1);
							if(field.allowedCaracters.indexOf(car) == -1)
							{
								valueCheck = valueCheck.replace(car, "")
							}
						}
						
						field.value = valueCheck;
						//alert(field.value);
					}		
				}
			}
			
			function SelectPage()
			{
			    var rdb = document.getElementById("rdbChoosePage");
			    if(rdb.checked)
			    {
			        if (document.all['txtChoosePage'].value == '')
			        {
			            var url = '<% =Url %>';
			            result = window.showModalDialog("<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>" + "/XmlEditor/PageSelector.aspx?AllowPositionSelection=true&disableNode=true"+"&pageUri="+url, null, "dialogHeight: 450px; dialogWidth: 350px; edge: Raised; center: Yes; help: No; scroll:no; resizable: no; status: No;");
			        }else
				        result = window.showModalDialog("<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>" + "/XmlEditor/PageSelector.aspx?AllowPositionSelection=true&currentPage=" + " " + "&disableNode=true"+"&pageUri="+document.all['txtChoosePage'].value, null, "dialogHeight: 450px; dialogWidth: 350px; edge: Raised; center: Yes; help: No; scroll:no; resizable: no; status: No;");
				    if (result.returnValue)
				    {
					    var res = result.selectedId.substr(2 + <%= CrossFactory.SiteNote.Components.Utils._ApplicationPath.Length %>);
					    res = res.replace(".off.aspx",".aspx");
					    var txt = document.getElementById("txtChoosePage");
					    txt.value = res;
				    }
				}
			}
			
			function WaitCursor()
			{
			
			    document.getElementsByTagName('body')[0].style.cursor = 'wait';
			}
			</script>
	</HEAD>
	<body style="margin:0px;" onload="load()">
		<form id="PageProperties" method="post" runat="server" onsubmit="WaitCursor();">
			<a id="size">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
				<TBODY>
					<tr>
						<td vAlign="top" width="100%" height="32">
							<table height="32" cellSpacing="0" cellPadding="0" width="100%" border="0">
								<tr>
									<td align="left" width="154" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/TopBackground.gif" colSpan="2"
									height="19"><IMG height="19" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/TopLeft.gif" width="154"></td>
									<td align="right" width="100%" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/TopBackground.gif" height="32"
									rowSpan="2"><IMG height="32" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/logo.gif" width="165"></td>
								</tr>
								<tr height="13">
									<td width="7" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/LeftBackgroundTop.gif" height="13"><IMG height="13" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="7"></td>
									<td width="147" height="13"><IMG height="13" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="147"></td>
								</tr>
							</table>
						</td>
					</tr>
					<tr height="100%">
						<td vAlign="top" width="100%" height="100%">
							<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
								<TBODY>
									<tr>
										<td width="7" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/LeftBackgroundBottom.gif"><IMG height="1" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="7"></td>
										<td width="5"><IMG height="1" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="5"></td>
										<td id="PageContent" vAlign="top" align="left" width="100%" height="100%">
											<table border="0" cellSpacing="0" cellPadding="0">
												<TBODY>
													<tr>
														<td colspan="4" class="cmMessageTitle"><b>Create page :</b></td>
													</tr>
													<tr>
														<td colspan="4"><asp:ValidationSummary runat="server" ID="ValidationSummary" ShowSummary="True" DisplayMode="List" CssClass="createPageValidator"></asp:ValidationSummary></td>
													</tr>
													<tr>
														<td colspan="4"><asp:Label id="lblResult" runat="server" Visible="False" CssClass="cmMessageUnable"></asp:Label></td>
													</tr>
													<tr>
														<td colspan="4" class="cmMessage"><b>The new page will be created as a subpage.</b></td>
													</tr>
													<tr>
														<td colspan="2" class="cmProperties" align="left">Page title :</td>
														<td><asp:textbox id="txtTitle" runat="server" Width="200" CssClass="cmtextbox"></asp:textbox></td>
														<td><asp:RequiredFieldValidator id="RFVPageTitle" runat="server" Display="Dynamic" ErrorMessage="* Page title required." Text="*" ControlToValidate="txtTitle" CssClass="createPageValidator"></asp:RequiredFieldValidator></td>
													</tr>
													<tr>
														<td colspan="2" class="cmProperties" align="left">Page name :</td>
														<td><asp:textbox id="txtName" runat="server" Width="200" CssClass="cmtextbox"></asp:textbox></td>
														<td><asp:RequiredFieldValidator id="RFVPageName" runat="server" Display="Dynamic" ErrorMessage="* Page name required." Text="*" ControlToValidate="txtName" CssClass="createPageValidator"></asp:RequiredFieldValidator>
														<asp:RegularExpressionValidator id="RegularExpressionValidatorName" runat="server" ValidationExpression="[\w\b\-_]+" Display="Dynamic" ControlToValidate="txtName" ErrorMessage="(2) Allowed characters: (a-z,A-Z,0-9,-,_)." Text="(2)" CssClass="createPageValidator"></asp:RegularExpressionValidator></td>
													<tr>
													    <!-- DUPLIQUER PAGE -->
													    <td><asp:RadioButton runat="server" ID="rdbChooseTemplate" AutoPostBack="True" Checked="true" /></td>
													    <!-- END DUPLIQUER PAGE -->
														<td class="cmProperties" align="left">Page template :</td>
														<td colspan="2"><asp:dropdownlist id="dropdownTemplate" runat="server" CssClass="cmtext"></asp:dropdownlist></td>
													</tr>
													<!-- DUPLIQUER PAGE -->
													<tr>
													    <td><asp:RadioButton runat="server" ID="rdbChoosePage" AutoPostBack="True" /></td>
													    <td class="cmProperties" align="left">Duplicate page :</td>
													    <td>
													        <asp:textbox id="txtChoosePage" Enabled="false" runat="server" Width="190" CssClass="cmtextbox"></asp:textbox>
													        <asp:RequiredFieldValidator id="RFVChoosePage" runat="server" Display="Dynamic" ErrorMessage="(3) Required field." Text="(3)" Enabled="false" ControlToValidate="txtChoosePage" CssClass="createPageValidator"></asp:RequiredFieldValidator>
													    </td>
													    <td><img id="imgFolder" runat="server" src="" onclick="SelectPage();" Height="20" Width="19" /></td>
													</tr>
													<tr>
													    <td></td>
													    <td></td>
													    <td class="cmDuplicate"><asp:CheckBox ID="chkDuplicate" runat="server" Enabled="false" /> Duplicate subpages</td>
													    <td></td>
													</tr>
													<!-- END DUPLIQUER PAGE -->
												</TBODY>
											</table>
										</td>
										<td width="5"><IMG height="1" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="5"></td>
										<td width="11" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/RightBackground.gif"><IMG height="1" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/transp.gif" width="11"></td>
									</tr>
								</TBODY>
							</table>
						</td>
					</tr>
					<tr height="40">
						<td>
							<table height="100%" cellSpacing="0" cellPadding="0" border="0">
								<tr>
									<td height="8"><IMG src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/FooterLeft.gif"></td>
									<td width="100%">
										<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
											<tr>
												<td width="100%" background="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/FooterCenter.gif" height="8"></td>
												<td height="8"><IMG height="8" src="<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/FooterRight.gif" width="255"></td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td align="right" width="100%" colspan="3">
										<table style="BACKGROUND: url(<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>/Admin/Images/Layout/Footer.gif) no-repeat right 50%" height="100%"
										width="100%" border="0">
											<tr>
												<td width="100%"></td>
												<td><asp:Button id="cmdSave" runat="server" Text="Create" Width="75" Height="23" CssClass="cmtext"
														OnClick="cmdSave_Click"></asp:Button></td>
												<td><input type="button" value="Cancel" onclick="ClosePage(null)" style="WIDTH:75px;HEIGHT:23px"
														class="cmtext" /></td>
												<td width="1"></td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</TBODY>
			</table>
			</a>
		</form>
	</body>
</HTML>
